<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>省钱控-最新优惠</title>
    <!-- 初始化样式 -->
    <link rel="stylesheet" href="./css/reset.css">
    <!-- 公共样式 -->
    <link rel="stylesheet" href="./css/common.css">
    <!-- 引入主页面 -->
    <link rel="stylesheet" href="./css/index.css">
    <!-- 引入当前页面文件 -->
    <link rel="stylesheet" href="./css/moneyctrl.css">


</head>
<body>
    <div class="view">
        <!-- 头部 -->
        <div class="head-top">
            <a href='index.html'><</a>
            <h1>省钱控 - 最新优惠</h1>
            <div class="app-dow">
                <a href='javascript:;'></a>
            </div>
        </div>

        <!-- 列表 -->
        <div class="recommend">
            <div class="recommend-main">
            </div>
            <!-- 上下页按钮 -->

            
        </div>

        <!-- 尾部 -->
        <footer>
            <div class="foot-top">
                <a href='javascript:;'>登录</a>
                <a href='javascript:;'>注册</a>
                <a href='javascript:;' class="go-top">
                    <img src="./images/gotop.jpg" alt="">
                    返回顶部
                </a>
            </div>
            <div class="foot-bottom">
                <p>
                    <a href='javascript:;'>手机APP下载</a>
                    <a href='javascript:;'>慢慢买手机版</a>
                    <a href='javascript:;'> -- 掌上比价平台</a>
                </p>
                <p>m.manmanbuy.com</p>
            </div>
        </footer>

        
    </div>
</body>
</html>
<script src="./lib/zepto.js"></script>
<script src="./lib/template.js"></script>
<script src="./js/htmlFontSize.js"></script>
<script src="./js/common.js"></script>
<!-- <script src="./lib/jquery.twbsPagination.js"></script> -->
<script src="./js/moneyctrl.js"></script>

<!-- 模板引擎 -->
<script type="text/template" id="moneyctrlTmp">
    <ul>
        {{each result as value key}}
        <li class="clearfix">
            <a href="moneyproduct.html?productid={{value.productId}}">
                <!-- 图片 -->
                <div class="pic">{{#value.productImgSm}}</div>
                <div class="clearfix explain">
                    <div class="top">
                        {{value.productName}}
                        <span>
                            {{value.productPinkage}}
                        </span>
                    </div>
                    <div class="bottom">
                        <span class="mall">{{value.productFrom}} | {{value.productTime}}</span>
                        <span class="comment">
                            <i class="icon-comment"></i>
                            {{value.productComCount.replace("有","").replace("人评论","")}}
                        </span>
                    </div>
                </div>
            </a>
        </li>
        {{/each}}
    </ul>
    <div class="clearfix page">
        <div class="page-btn"><a href="moneyctrl.html?pageid={{pageid-1}}">上一页</a></div>
        <div class="page-btn">
            <select id="selectPage" name="select" selected="">
                    {{each page as value i}}
                        {{if value.pageid == pageid}}
                        <option value="{{value.pageid}}" selected="selected">{{value.pageid}}/{{value.pageCount}}</option>	        		
                        {{else}}
                            <option value="{{value.pageid}}">{{value.pageid}}/{{value.pageCount}}</option>
                        {{/if}}
                    {{/each}}
            </select>
        </div>
        <div class="page-btn"><a href="moneyctrl.html?pageid={{pageid-1+2}}">下一页</a></div>
    </div>


</script>

<script>
    //获取url中的pageid
    (function($){
        $.covertToObj=function (str) {
        // "?id=5&name=jack&age=20" ==>{id:5,name:'jack',age:20} 
        // 1. 截取指定的字符串
        str = str.slice(1); // 从索引为1的位置开始截取截取到最后 "id=5&name=jack&age=20"
        // console.log(str);
        // 2. 切割这个字符串
        var arr = str.split("&"); // ["id=5","name=jack","age=20"]
        // console.log(str);
        // 3. 循环遍历这个数组 变成对象的形式
        var obj = {};
        for (var i = 0; i < arr.length; i++) {
        var temp = arr[i].split("="); // ["id","5"] ["name","jack"]
        //  console.log(temp);
        obj[temp[0]] = temp[1];
        // console.log(obj);  //  {id: "5", name: "jack", age: "20"}
        }

        // 4. 返回这个对象
        return obj;
  }
    })($);
    console.log($.covertToObj(location.search).pageid);
</script>